package org.display.util
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.*;
	
	import mx.flash.UIMovieClip;
	
	import org.data.*;
	import org.display.graphic.*;
	import org.display.graphic.line.RotLine;
	import org.utils.*;

	public class ShowAllXML
	{
		var num:Number=0
		var ivcOld:IvContainer

		public function ShowAllXML(tab,scene,sceneTab,umlScene)
		{
			
			var xmlFile:File=File.documentsDirectory.resolvePath((Global.workspace+"\\xml").replace(/\\/gis,"/"))
			
			if(xmlFile.exists == false){return;}	
			
			loadxml(xmlFile,tab,scene,sceneTab,umlScene)
			
			Global.selectPath=""
				
			Global.jsflsPath=[]
		}
		

		function loadxml(file,tab,scene,sceneTab,umlScene){
			
			var files:Array=file.getDirectoryListing() 
			
			for(var i=0;i<files.length;i++){
				
				if(files[i].isDirectory){
					
					loadxml(files[i],tab,scene,sceneTab,umlScene)
					
				}else{
					
					Global.selectPath=files[i].url
						
					setTimeout(function(path,tab,scene,sceneTab,i){
						
						var ivc:IvContainer=new IvContainer(path,tab,scene,sceneTab)
						umlScene.addChild(ivc);

						Global.jsflsPath.push({iv:"",ivc:ivc,path:path.replace(/\/xml\//gis,"\/jsfl\/").replace(/\.xml/gis,".jsfl"),ivname:path.split("\/")[path.split("\/").length-1].replace(/\.xml/gis,"")})
						
						if(ivcOld==null){
							ivc.x=0;ivc.y=0;}
						else{
							var rec:Rectangle=ivcOld.getBounds(ivcOld.parent)
							ivc.x=ivcOld.x+rec.width
							ivc.y=ivcOld.y
						}	
						
						ivcOld=ivc
						
						trace(files.length-1,i)
						

					},num+=200,Global.selectPath.replace(/\\/gis,"\/"),tab,scene,sceneTab,i)

				}
			}
			
			
			//setTimeout(orderY,num+3000)
			
		}
		
		
		
		

		
	}
}